{extend name="../../../view/public/base" /}

{block name="css"}
<style>
    body {
        background-color: #F2F2F2;
    }
</style>
{/block}

{block name="body"}
<div style="padding: 20px; background-color: #F2F2F2;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card" style="padding: 10px">
                <form class="layui-form" lay-filter="addForm" autocomplete="off">
                    <!--租户ID-->
                    <div class="layui-form-item layui-hide">
                        <label class="layui-form-label">租户ID</label>
                        <div class="layui-input-block">
                            <input type="number" name="member_id" placeholder="请输入租户ID" class="layui-input" value="{$row.member_id}">
                        </div>
                    </div>
                    <!--帐号余额-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">帐号余额:{$row.money}</label>
                        <div class="layui-input-inline">
                            <input type="number" name="money" placeholder="请输入帐号余额" class="layui-input" value="0">
                        </div>
                    </div>
                    <!--冻结金额-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">冻结金额:{$row.freeze_money}</label>
                        <div class="layui-input-inline">
                            <input type="number" name="freeze_money" placeholder="请输入冻结金额" class="layui-input" value="0">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submitBtn">立即提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{/block}

{block name="js"}
<script>
    var layer, form, bwajax, upload, $, laydate;

    layui.use(['layer', 'form', 'bwajax', 'upload', 'laydate'], function () {
        layer = layui.layer;
        form = layui.form;
        bwajax = layui.bwajax.instance();
        upload = layui.upload;
        $ = layui.jquery;
        laydate = layui.laydate;

        //监听提交按钮
        form.on('submit(submitBtn)', function (obj) {
            data = obj.field;

            if(!data.member_id) {layer.msg('租户ID不能为空', {icon: 2});return false}
            if(!data.money) {layer.msg('帐号余额不能为空', {icon: 2});return false}
            if(!data.freeze_money) {layer.msg('冻结金额不能为空', {icon: 2});return false}


            //ajax调用后台接口
            bwajax.post("{:Url('/manage/admin/member/wallet/edit')}?id={$row.id}", data)
                .then(function (response) {
                    if (response.data.data.errcode === 0) {
                        layer.msg('提交成功', {icon: 1});
                        submitSuccess();
                    } else {
                        layer.msg(response.data.msg, {icon: 2});
                    }
                })

            return false;
        })
    });
</script>
{/block}